<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    'use strict'
    // class 关键字是 ES6 引入的
    // 定义一个对象
    class Student{

        constructor(name) {
            this.name = name;
        }

        hello() {
            alert("hello");
        }
    }

    // 创建对象
    let xiaoming = new Student("xiaoming");
    console.log(xiaoming.name);
    xiaoming.hello();

    // 继承
    class XiaoStudent extends Student{
        constructor(name, grade) {
            super(name);
            this.grade = grade;
        }

        myGrade() {
            alert("我是小学生。。。")
        }
    }

    let xiao = new XiaoStudent("小学生", 1);
    xiao.hello();
    xiao.myGrade();
    console.log(xiao.name);

</script>

</body>
</html>